package com.ljx.controller;

import com.alibaba.excel.annotation.ExcelProperty;
import com.ljx.common.ResponseResult;
import com.ljx.domain.dto.TagListDto;
import com.ljx.domain.entity.Tag;
import com.ljx.domain.vo.PageVo;
import com.ljx.domain.vo.TagVo;
import com.ljx.service.TagService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 李捷禧
 * Date: 2023/4/21
 * ClassName: TagController
 */

@RestController
@RequestMapping("/content/tag")
public class TagController {
    @Autowired
    private TagService tagService;

    @GetMapping("/list")
    public ResponseResult<PageVo> list(Integer pageNum, Integer pageSize, TagListDto tagListDto){
        return tagService.pageTagList(pageNum,pageSize,tagListDto);
    }
    @GetMapping("/listAllTag")
    public ResponseResult listAllTag(){
        List<TagVo> list = tagService.listAllTag();
        return ResponseResult.okResult(list);
    }

    @PostMapping
    public ResponseResult addTag(@RequestBody Tag tag){
        return tagService.addTag(tag);
    }

    @GetMapping("/{id}")
    public ResponseResult getTag(@PathVariable Long id){
        return tagService.getTag(id);
    }

    @PutMapping
    public ResponseResult update(@RequestBody Tag tag){
        tagService.updateById(tag);
        return ResponseResult.okResult("更新成功");
    }

//    @DeleteMapping("{id}")
//    public ResponseResult deleteTag(@PathVariable Long id){
//        tagService.removeById(id);
//        return ResponseResult.okResult("删除成功");
//    }

    @DeleteMapping("/{id}")
    public ResponseResult deleteByIds(@PathVariable List<Long> id){
        tagService.removeByIds(id);
        return ResponseResult.okResult("删除成功");
    }


}

